/**
 * @description 转树形结构 顺便添加label和value属性
 *
 * */
export const translateTree = (array:Array<object>,rootId:string|number) => {
    let result:any = []
    array.forEach((item:any) => {
        item['label'] = item.cateName
        item['value'] = item.cateId
        item['key'] = item.cateId
        if(item.cateParentId == rootId) {
            result.push(item)
            item.children = translateTree(array,item.cateId)
        }
    })
    return result
}

/**
 * @description 随机设置当前标签的颜色
 * */

export const randomColor = () => {
    let corloArr = ['processing','success','error','warning','magenta','red','volcano','orange','gold','lime','green','cyan','blue','geekblue','purple']
    return corloArr[Math.floor(Math.random()*corloArr.length)]
}


export function isMobile(){
    if(window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {
        return true; // 移动端
    }else{
        return false; // PC端
    }
}
